def min_length(array, val):
    cur_sum = 0
    start = 0
    min_len = len(array)+1
    for end in range(len(array)):
        cur_sum += array[end]
        while cur_sum - array[start] >= val:
            cur_sum -= array[start]
            start += 1
        if cur_sum >= val and end - start + 1 < min_len:
            min_len = end - start + 1
    return min_len if min_len < len(array)+1 else 0

print(min_length([2,3,1,2,4,3], 7))
